<?php echo $this->Html->script('jquery-ui-1.8.2.custom.min'); ?>
<script type="text/javascript">
	//<![CDATA[
        $(document).ready(function () {
             $('#tabs-message ul > li a').bind("click", function (event) {
                var strErgExp = /#m-/g;
                var tabIndex = ''

                var divContent = $(this).attr('href');
                tabIndex = divContent.replace(strErgExp, '');

                $('#tabs-message ul > li').removeClass('ui-tabs-selected ui-state-active');
                $('#' + tabIndex).addClass('ui-tabs-selected ui-state-active');
                if(divContent == '#m-tabs-1'){
                     $('#tabs-message div.company-tabs-panel').addClass('ui-tabs-hide');
                     $(divContent).removeClass('ui-tabs-hide');
                }else{
                    $.ajax({
                            dataType:"html",
                            error:function (XMLHttpRequest, textStatus, errorThrown) {
                                $('#tabs-message div.company-tabs-panel').addClass('ui-tabs-hide');
                                $(divContent).html("Couldn't load this tab. We'll try to fix this as soon as possible.");
                                $(divContent).removeClass('ui-tabs-hide');
                            },
                            success:function (data, textStatus) {
                                $('#tabs-message div.company-tabs-panel').addClass('ui-tabs-hide');
                                $(divContent).html(data);
                                $(divContent).removeClass('ui-tabs-hide');
                            },
                            type:"GET",
                            url: "<?php echo Router::url(array('action' => 'messageSent')) ?>"
                 });
                  
                }
                  return false;
             });
             $('#tabs-message ul > li.ui-state-default').bind('mouseover', function(event){
                $(this).addClass('ui-state-hover');
                return false;
            });
            $('#tabs-message ul > li.ui-state-default').bind('mouseout', function(event){
                $(this).removeClass('ui-state-hover');
                return false;
            });
              return false;
        });
        //]]>
</script>
<?php if($this->Bayon->isLogging()){?>
	<div id="left_column" class="column_left">
            	<?php echo $this->element('user/left_user_home_menu'); ?>
        </div>
	<div id="right_column" class="column_right">
            <div id="main-content">
            <div id="display_notice"></div>
                <?php echo $this->Session->flash(); ?>
		<div id="form_notice">
		<?php
			echo $this->element( 'message/message_form', $sentTo);
		?>
                </div>
		<div id="message_error">
		</div>
		<div  id="content_notice">
                    <div id="tabs-message" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
                        <?php
                            $li = $this->Html->tag('li', $this->Html->link(__('Inbox', true), '#m-tabs-1'), array('id' => 'tabs-1', 'class' => 'ui-state-default ui-corner-top ui-tabs-selected ui-state-active'));
                            $li .= $this->Html->tag('li', $this->Html->link(__('Sent', true), '#m-tabs-2'), array('id' => 'tabs-2', 'class' => 'ui-state-default ui-corner-top'));
                            echo $this->Html->tag('ul', $li, array("class" => "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"));
                        ?>

                        <div id="m-tabs-1" class="company-tabs-panel">
                            <?php echo $this->element('message/render', $messages); ?>
                        <div class="paging clearfix">
                            <p class="before"><?php echo $this->Paginator->prev(__('« Previous', true), array(), null, array('class'=>'disabled'));?></p>
                            <p class="more"><?php echo $this->Paginator->next(__('Next »', true), array(), null, array('class' => 'disabled'));?></p>
                        </div>
                        </div>
                        <div id="m-tabs-2" class="company-tabs-panel ui-tabs-hide">
                               
                        </div>
                    </div>
                    
		</div>
            </div> <!-- end main -->
            <div id="main-right">

            </div>
	</div><!-- end right-column -->
<?php }else{
	$this->set('home', true);
 }
 ?>
 <script type="text/javascript">
     //<![CDATA[
     $(document).ready(function(){
                $("ul > li.notice").bind('mouseover', function(){
                    var actionId ='#ul_' + $(this).attr('id');
                    $(actionId).addClass('actions-active');
                });
                $("ul > li.notice").bind('mouseout', function(){
                    var actionId ='#ul_' + $(this).attr('id');
                    $(actionId).removeClass('actions-active');
                });

             $('#tabs-1').removeClass('ui-tabs-panel ui-widget-content ui-corner-bottom');
             $('#tabs-1').addClass('message-panel');

         });
    //]]>
</script>